import SwiftUI

struct SearchView: View {
    
    @Binding var searchContent: String
    @FocusState var textFocused: Bool
    
    var searchAction: () -> Void
    
    var body: some View {
        HStack(spacing: 4.0) {
            Image(.iconSearch)
            TextField("搜索", text: $searchContent)
                .submitLabel(.search)
                .onSubmit {
                    textFocused = false
                    searchAction()
                }
                .font(.alibabaPuHuiTi(size: 16.0, weight: .regular))
                .foregroundStyle(Color.fs9C9C9C)
                .focused($textFocused)
        }
        .padding(.horizontal, 16.0)
        .padding(.vertical, 12.0)
        .background(
            Capsule()
                .fill(.fsFFFFFF)
        )
    }
}

#Preview {
    SearchView(searchContent: .constant(""), searchAction: {})
}
